{% extends "layouts/base.html" %}
{% load book_extras %}
{% block title %} Management {% endblock %} 

{% block stylesheets %}{% endblock stylesheets %}

{% block content %}

<div class="pcoded-content">
    <div class="pcoded-inner-content">
        <div class="page-header">
            <div class="page-block">
                <!-- Title -->
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10">书籍类别管理</h5>

                        </div>

                    </div>
                </div>
            </div>

        </div>

        <br>
        <!-- [ breadcrumb ] end -->
        <div class="main-body">
            <div class="page-wrapper">
                <!-- [ Main Content ] start -->
                <div class="row">
                    <!-- [ basic-table ] start -->
                    <div class="col-xl-12">
                        <div class="card">
                            <div class="card-header">
                                <h5>总共 {{count_total}} 种类别</h5>
                            </div>
                            
                            {% show_messages %}

                            <div class="card-block ">
                                <div class='row'>
                                    <!-- Sort by -->
                                    <div class="col-6">
                                        <b>排序方式：  </b>
                                        <a href="{% url 'category_list' %}?search={{search}}&orderby=id">编号</a>  |
                                        <a href="{% url 'category_list' %}?search={{ search }}&orderby=name">类别名</a> |
                                        <a href="{% url 'category_list' %}?search={{ search }}&orderby=created_at">创建时间</a>
                                    </div>
                                     <!-- Search box -->
                                    <div class="col-6">
                                        <form class="form-inline mb-2">
                                            <div class="form-group mx-sm-3 mb-2">
                                                <input type="text" 
                                                       class="form-control" 
                                                       name="search",
                                                       id='search',
                                                       placeholder="Search category",
                                                       value={{search}}
                                                       >
                                            </div>
                                            <button type="submit" class="btn btn-secondary mb-2 btn-sm">搜索</button>
                                        </form>
                                    </div>
                                </div>
                                
                                <div class="table-responsive table-hover">
                                    <!-- Table -->
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>类别名</th>
                                                <th>创建时间</th>
                                                <th>###</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            
                                            {% for cat in categories %}
                                            <tr>
                                                <th scope="row">{{cat.id}}</th>
                                                <td>{{cat.name}}</td>
                                                <td>{{ cat.created_at|date:"Y-m-d H:i" }}  </td>
                                                <td><a href="{% url 'category_delete' cat.pk %}" class="badge badge-danger"><i class="feather icon-trash-2"></i>&nbsp;删除</a></td>

                                            </tr>
                                            {% endfor %}


                                        </tbody>
                                    </table>
                                </div>
                                <div class="row">
                                    <!-- Add button -->
                                    <div class='col-6'>
                                        <a href="{% url 'category_create' %}" class='btn btn-primary'>添加类别</a>
                                    </div>
                                    <!-- Paginations -->
                                    <div class='col-6'>
                                        {% show_pagination %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                </div>
                <!-- [ Main Content ] end -->
            </div>
        </div>
    </div>
</div>

{% endblock content %}

<!-- Specific Page JS goes HERE  -->
{% block javascripts %}{% endblock javascripts %}
